HTMLModelElement: ready property
The HTMLModelElement
ready
is a Promise
that reflects the ready-state of a model's currentSrc resource. It is resolved when a valid model resource is loaded and processed, or is rejected if for any reason the resource cannot be used.
Note: Because a model's rendering depends necessarily on a valid model resource and optionally on an environment map resource, it is important to wait for both to expect a given model to be ready for display.
Examples
This example demonstrates how to confirm that both a model's scene and environment map resources are ready for rendering, and how to gracefully address failed parsing:
const modelElem = document.getElementById("model");
model.setAttribute("src", "./teapot.usdz");
model.setAttribute("environmentmap", "./night.hdr");
Promise.all([model.ready, model.environmentMapReady])
.then(enhanceWithModel)
.error(showModelError);
In this example, the display of the model is prevented until both resource-related Promise objects are resolved. If processing fails on either resource, the showModelError()
function is called to display any relevant fallback capability to the user.
Specifications
No specification found
No specification data found for api.HTMLModelElement.ready
.
Check for problems with this page or contribute a missing spec_url
to mdn/browser-compat-data. Also make sure the specification is included in w3c/browser-specs.